package com.star.common.email.response;

import lombok.Data;

/**
 * 返回值对象
 *
 * @author zhouhengzhe
 * @version 1.0
 * @date 2023/6/16 11:47
 */
@Data
public class Result<T> {

    private Integer code;

    private String msg;

    private T data;

    public Result(T data) {
        this.code = 200;
        this.msg = "成功";
        this.data = data;
    }

    public Result(Integer code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public static <T> Result<T> success(T data) {
        return new Result<>(data);
    }

    public static <T> Result<T> success() {
        return new Result<>(null);
    }
    public static <T> Result<T> fail(T data) {
        return new Result<>(500, "失败", data);
    }


    public static <T> Result<T> fail(String message) {
        return new Result<>(500, message, null);
    }
}
